<?php
require 'lib/init.php';

//分页
$_GET['cat_id']=isset($_GET['cat_id'])?$_GET['cat_id']:3;
$total=mGetOne('select count(*) from article where cat_id='.$_GET['cat_id'].';');
$pageSize=1;
$currentPage=isset($_GET['page'])?$_GET['page']:1;
$pages=pages($total,$pageSize,$currentPage);

if(isset($_GET['cat_id'])){
    $where="and article.cat_id=$_GET[cat_id]";
}else{
    $where='';
}
$cats=mGetAll('select * from cat');
$start=($currentPage-1)*$pageSize;
$arts=mGetAll("select article.*,cat.cat_name from article left join cat on article.cat_id=cat.cat_id where 1 $where order by art_id desc limit $start,$pageSize;");
require 'view/front/index.html';
